package com.kcs.fxmargin.service;

import com.kcs.common.utils.ConnectionUtils;
import com.kcs.common.utils.Constant;
import com.kcs.fxmargin.bo.MainPageBO;
import com.kcs.fxmargin.dao.MainPageDAO;
import java.sql.Connection;

import org.apache.log4j.Logger;

public class MainPageService {
	
	private Logger log = Logger.getLogger(Constant.LOG_FX);

	public MainPageBO getActionRoleFlag(MainPageBO model)throws Exception{
        Connection conn = null;
        MainPageDAO dao = null;
        
        log.info("Begin : MainPageService : getActionRoleFlag");
        
        try{
            if(validateGetUserData(model)){
                conn = ConnectionUtils.getConnection(Constant.MSSQL, Constant.TO);
                dao = new MainPageDAO();
                model = dao.getActionRoleFlag(model, conn);
            }
        }
        catch(Exception e)
        {
            throw e;
        }finally{
        	if(conn != null){
	            try{
	                conn.close();
	            }catch(Exception ex){
	                throw ex;
	            }
        	}
        }
        
        log.info("End : MainPageService : getActionRoleFlag");
        return model;
	}
	
	public boolean validateGetUserData(MainPageBO model)throws Exception {
		return !model.getActionPath().equals("") && !model.getRoleId().equals("");
	}
}